﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

//using PowerCreator.LMS.Logic.Common;
//using PowerCreator.LMS.Logic.ProjectManager;
//using PowerCreator.LMS.Model.Entity;
//using PowerCreator.LMS.Logic.Fpager;
//using PowerCreator.LMS.Logic.CourseManager;
//using PowerCreator.LMS.Logic.QuestionManager;
//using PowerCreator.LMS.Logic.PaperManager;
using System.Text;

public partial class sysadmin_CountManager_UserProjectScheduleInfo_New : System.Web.UI.Page
{
    //ManagerClassInfo objClassInfoLogic = new ManagerClassInfo();
    //ManagerClassMember objManagerClassMember = new ManagerClassMember();
    //ManagerProjectResource objprojectresourcelogic = new ManagerProjectResource();
    //ManagerProjectSchedule objprojectschedulelogic = new ManagerProjectSchedule();
    //ManagerProjectInfo projectManager = new ManagerProjectInfo();
    //ManagerPaperInfo paperManager = new ManagerPaperInfo();
    //ManagerCourseInfo courseManager = new ManagerCourseInfo();

    const string TABLE_BEGIN = "<table class=\"List-G\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" >";
    const string TABLE_END = "</table>";
    const string TABLE_TH_BEGIN = "<TH >";
    const string TBALE_TH_END = "</TH>";
    const string TABLE_TR_BEGIN = "<tr  onmouseover=\"this.style.backgroundColor='#FAEDB8'\" onmouseout=\"this.style.backgroundColor='#F7FAFF'\">";
    const string TBALE_TR_END = "</tr>";
    const string TBALE_TD_BEGIN = "<td >";
    const string TBALE_TD_END = "</td>";

    

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
        //    string ProjectID = Base64.Decode(Request.QueryString["p"].ToString());
        //    ViewState.Add("ProjectID", ProjectID);
        //    ProjectInfo info = new ProjectInfo();
        //    info = projectManager.Load(int.Parse(ProjectID));

        //    ViewState.Add("ProjectName", info.ProjectName);
        //    lab_ProjectName.Text = info.ProjectName;

        //    BandClassName();

        //    string search = GetSearch();
        //    BinderPager(search);
        //    BinderGV(search, 1);

        }
    }
    private void BandClassName()
    {
        //string search = string.Format("ProjectID={0}", ViewState["ProjectID"].ToString());
        //dpdlst_ClassName.DataSource = objClassInfoLogic.Query(search);
        //dpdlst_ClassName.DataTextField = "ClassName";
        //dpdlst_ClassName.DataValueField = "ClassID";
        //dpdlst_ClassName.DataBind();
    }
    private string GetSearch()
    {
        StringBuilder search =new  StringBuilder();
        //search.Append(" and ProjectID="+ViewState["ProjectID"].ToString());
        //if (!string.IsNullOrEmpty(txtUserName.Text.Trim()))
        //{
        //    search.Append(" and RealName like '%"+txtUserName.Text+"%' ");
        //}
        //if (dpdlst_ClassName.SelectedValue!="-1")
        //{
        //     search.Append(" and ClassID="+dpdlst_ClassName.SelectedValue);
        //}


        return search.ToString();
    }
    private void BinderPager(string search)
    {

        //AspNetPager1.RecordCount = objManagerClassMember.GetProjectUserListCount(search);
        //AspNetPager1.PageSize = FBasePage.PageSize();
    }
    private void BinderGV(string search, int pageIndex)
    {
        //StringBuilder str_table=new StringBuilder();
        //DataTable dt_ProjectUserList = new DataTable();
        //dt_ProjectUserList = objManagerClassMember.GetProjectUserList(search, pageIndex, FBasePage.PageSize());

        //DataTable dt_UserProjectSchedule = new DataTable();
        ////string search_ProjectSchedule = string.Empty;
        ////if (dpdlst_ClassName.SelectedValue == "-1")
        ////{
        ////    search_ProjectSchedule = " and ProjectID="+ViewState["ProjectID"].ToString();
        ////}
        ////else
        ////{
        ////    search_ProjectSchedule = "and ProjectID=" + ViewState["ProjectID"].ToString()+" and ClassID="+dpdlst_ClassName.SelectedValue;
        ////}

        

        //str_table.Append(TABLE_BEGIN);
        //str_table.Append(TABLE_TR_BEGIN);

        //str_table.Append(TABLE_TH_BEGIN);
        //str_table.Append("员工");
        //str_table.Append(TBALE_TH_END);

        //str_table.Append(TABLE_TH_BEGIN);
        //str_table.Append("资源名称");
        //str_table.Append(TBALE_TH_END);

        //str_table.Append(TABLE_TH_BEGIN);
        //str_table.Append("起始时间");
        //str_table.Append(TBALE_TH_END);

        //str_table.Append(TABLE_TH_BEGIN);
        //str_table.Append("终止时间");
        //str_table.Append(TBALE_TH_END);

        //str_table.Append(TABLE_TH_BEGIN);
        //str_table.Append("状态");
        //str_table.Append(TBALE_TH_END);

        //str_table.Append(TABLE_TH_BEGIN);
        //str_table.Append("课件总点击次数");
        //str_table.Append(TBALE_TH_END);

        //str_table.Append(TABLE_TH_BEGIN);
        //str_table.Append("课件总时长(分钟)");
        //str_table.Append(TBALE_TH_END);

        //str_table.Append(TABLE_TH_BEGIN);
        //str_table.Append("考试次数");
        //str_table.Append(TBALE_TH_END);

        //str_table.Append(TABLE_TH_BEGIN);
        //str_table.Append("试卷总分");
        //str_table.Append(TBALE_TH_END);

        //str_table.Append(TABLE_TH_BEGIN);
        //str_table.Append("试卷实际得分");
        //str_table.Append(TBALE_TH_END);

        ////str_table.Append(TBALE_TD_BEGIN);
        ////str_table.Append("查看详细");
        ////str_table.Append(TBALE_TD_END);

        //str_table.Append(TBALE_TR_END);
        //ViewState["dt"] = dt_ProjectUserList;
        //for (int j = 0; j < dt_ProjectUserList.Rows.Count; j++)
        //{

        //    string search_UserProjectScheduleList = search + " and UserID=" + dt_ProjectUserList.Rows[j]["UserID"].ToString();
        //    int count = objprojectschedulelogic.SearchUserProjectSchedule_UserListCount(search_UserProjectScheduleList);
        //    dt_UserProjectSchedule = objprojectschedulelogic.SearchUserProjectSchedule_UserList(search_UserProjectScheduleList, 1, count);

           
        //    for (int i = 0; i < dt_UserProjectSchedule.Rows.Count; i++)
        //    {
        //        str_table.Append(TABLE_TR_BEGIN);

        //        if (i == 0)
        //        {
        //            str_table.Append("<td " + "rowspan=\"" + count + "\" >");
        //            str_table.Append(dt_ProjectUserList.Rows[j]["RealName"].ToString());
        //            str_table.Append(TBALE_TD_END);
        //        }

               

        //        str_table.Append(TBALE_TD_BEGIN);
        //        str_table.Append(dt_UserProjectSchedule.Rows[i]["ResourceName"].ToString());
        //        str_table.Append(TBALE_TD_END);

        //        str_table.Append(TBALE_TD_BEGIN);
        //        if (string.IsNullOrEmpty(dt_UserProjectSchedule.Rows[i]["StartTime"].ToString()))
        //        {
        //            str_table.Append("--");
        //        }
        //        else
        //        {
        //            str_table.Append(dt_UserProjectSchedule.Rows[i]["StartTime"].ToString());
        //        }
        //        str_table.Append(TBALE_TD_END);

        //        str_table.Append(TBALE_TD_BEGIN);
        //        if (string.IsNullOrEmpty(dt_UserProjectSchedule.Rows[i]["EndTime"].ToString()))
        //        {
        //            str_table.Append("--");
        //        }
        //        else
        //        {
        //            str_table.Append(dt_UserProjectSchedule.Rows[i]["EndTime"].ToString());
        //        }
        //        str_table.Append(TBALE_TD_END);

        //        str_table.Append(TBALE_TD_BEGIN);
        //        if (string.IsNullOrEmpty(dt_UserProjectSchedule.Rows[i]["State"].ToString()))
        //        {
        //            str_table.Append("未开始");
        //        }
        //        else if(dt_UserProjectSchedule.Rows[i]["State"].ToString()=="1")
        //        {
        //            str_table.Append("进行中");
        //        }
        //        else if (dt_UserProjectSchedule.Rows[i]["State"].ToString() == "2")
        //        {
        //            str_table.Append("未通过");
        //        }
        //        else if (dt_UserProjectSchedule.Rows[i]["State"].ToString()== "3")
        //        {
        //            str_table.Append("通过");
        //        }
        //        else if (dt_UserProjectSchedule.Rows[i]["State"].ToString()== "4")
        //        {
        //            str_table.Append("批阅中");
        //        }
        //        else if (dt_UserProjectSchedule.Rows[i]["State"].ToString() == "5")
        //        {
        //            str_table.Append("补考");
        //        }
        //        str_table.Append(TBALE_TD_END);

        //        str_table.Append(TBALE_TD_BEGIN);
        //        if (string.IsNullOrEmpty(dt_UserProjectSchedule.Rows[i]["ClickCount"].ToString()))
        //        {
        //            str_table.Append("--");
        //        }
        //        else
        //        {
        //            str_table.Append(dt_UserProjectSchedule.Rows[i]["ClickCount"].ToString());
        //        }
        //        str_table.Append(TBALE_TD_END);

        //        str_table.Append(TBALE_TD_BEGIN);
        //        if (string.IsNullOrEmpty(dt_UserProjectSchedule.Rows[i]["VideoTime"].ToString()))
        //        {
        //            str_table.Append("--");
        //        }
        //        else
        //        {
        //            str_table.Append(dt_UserProjectSchedule.Rows[i]["VideoTime"].ToString());
        //        }

        //        str_table.Append(TBALE_TD_END);

        //        str_table.Append(TBALE_TD_BEGIN);
        //        if (string.IsNullOrEmpty(dt_UserProjectSchedule.Rows[i]["ExamCount"].ToString()))
        //        {
        //            str_table.Append("--");
        //        }
        //        else
        //        {
        //            str_table.Append(dt_UserProjectSchedule.Rows[i]["ExamCount"].ToString());
        //        }

        //        str_table.Append(TBALE_TD_END);

        //        str_table.Append(TBALE_TD_BEGIN);
        //        if (string.IsNullOrEmpty(dt_UserProjectSchedule.Rows[i]["PaperScore"].ToString()))
        //        {
        //            str_table.Append("--");
        //        }
        //        else
        //        {
        //            str_table.Append(dt_UserProjectSchedule.Rows[i]["PaperScore"].ToString());
        //        }

        //        str_table.Append(TBALE_TD_END);

        //        str_table.Append(TBALE_TD_BEGIN);
        //        if (string.IsNullOrEmpty(dt_UserProjectSchedule.Rows[i]["LastScore"].ToString()))
        //        {
        //            str_table.Append("--");
        //        }
        //        else
        //        {
        //            str_table.Append(dt_UserProjectSchedule.Rows[i]["LastScore"].ToString());
        //        }
        //        str_table.Append(TBALE_TD_END);

        //        str_table.Append(TBALE_TR_END);

        //        //str_table.Append(TBALE_TD_BEGIN);
        //        //str_table.Append("查看详细");
        //        //str_table.Append(TBALE_TD_END);

        //    }
        //}
       
        //str_table.Append(TABLE_END);

        //lab_table.Text = str_table.ToString();   

    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string search = GetSearch();
        BinderPager(search);
        BinderGV(search, 1);
    }
    protected void btnExport_Click(object sender, EventArgs e)
    {
        
        DataTable dt_ProjectUserList = (DataTable)ViewState["dt"];
        ExportList(dt_ProjectUserList);
    }
    private void ExportList(DataTable dt_ProjectUserList)
    {
        //ArrayList list = new ArrayList();
        //DataTable dt_UserProjectSchedule = new DataTable();
        //for (int i = 0; i < dt_ProjectUserList.Rows.Count; i++)
        //{
        //    string search = GetSearch();
        //    string search_UserProjectScheduleList = search + " and UserID=" + dt_ProjectUserList.Rows[i]["UserID"].ToString();
        //    int count = objprojectschedulelogic.SearchUserProjectSchedule_UserListCount(search_UserProjectScheduleList);
        //    if (dt_UserProjectSchedule != null)
        //    {
        //        dt_UserProjectSchedule.Merge(objprojectschedulelogic.SearchUserProjectSchedule_UserList(search_UserProjectScheduleList, 1, count));
        //    }
        //    else
        //    {
        //        dt_UserProjectSchedule = objprojectschedulelogic.SearchUserProjectSchedule_UserList(search_UserProjectScheduleList, 1, count);
        //    }
        //}

        //dt_UserProjectSchedule.Columns.Add("状态");
        //for (int i = 0; i < dt_UserProjectSchedule.Columns.Count; i++)
        //{
            
            
        //    string columnName = dt_UserProjectSchedule.Columns[i].ColumnName;
        //    if (columnName == "ResourceName")
        //    {
        //        dt_UserProjectSchedule.Columns[i].ColumnName = "资源名称";
        //        dt_UserProjectSchedule.Columns[i].SetOrdinal(1);

        //    }
        //    else if (columnName == "RealName")
        //    {
        //        dt_UserProjectSchedule.Columns[i].ColumnName = "员工";
        //        dt_UserProjectSchedule.Columns[i].SetOrdinal(0);

        //    }

        //    else if (columnName == "StartTime")
        //    {
        //        dt_UserProjectSchedule.Columns[i].ColumnName = "起始时间";
        //        dt_UserProjectSchedule.Columns[i].SetOrdinal(2);

        //    }
        //    else if (columnName == "EndTime")
        //    {
        //        dt_UserProjectSchedule.Columns[i].ColumnName = "终止时间";
        //        dt_UserProjectSchedule.Columns[i].SetOrdinal(3);

        //    }
        //    else if (columnName == "状态")
        //    {
        //        dt_UserProjectSchedule.Columns[i].SetOrdinal(4);
        //    }
        //    else if (columnName == "State")
        //    {
        //        list.Add(dt_UserProjectSchedule.Columns[i].ColumnName);

        //        //dt_UserProjectSchedule.Columns[i].SetOrdinal(4);

        //        for (int n = 0; n < dt_UserProjectSchedule.Rows.Count; n++)
        //        {


        //            switch (dt_UserProjectSchedule.Rows[n]["State"].ToString())
        //            {
        //                case "":
        //                    dt_UserProjectSchedule.Rows[n]["状态"] = "未开始";
        //                    break;
        //                case "1":
        //                    dt_UserProjectSchedule.Rows[n]["状态"] = "进行中";
        //                    break;
        //                case "2":
        //                    dt_UserProjectSchedule.Rows[n]["状态"] = "未通过";
        //                    break;
        //                case "3":
        //                    dt_UserProjectSchedule.Rows[n]["状态"] = "通过";
        //                    break;
        //                case "4":
        //                    dt_UserProjectSchedule.Rows[n]["状态"] = "批阅中";
        //                    break;
        //                case "5":
        //                    dt_UserProjectSchedule.Rows[n]["状态"] = "补考";
        //                    break;

        //            }
        //        }


        //        //dt.Columns[i].ColumnName = "状态";
        //        //dt.Columns[i].DataType = System.Type.GetType("string");
        //    }
        //    else if (columnName == "ClickCount")
        //    {
        //        dt_UserProjectSchedule.Columns[i].ColumnName = "课件总点击次数";
        //        dt_UserProjectSchedule.Columns[i].SetOrdinal(5);

        //    }
        //    else if (columnName == "VideoTime")
        //    {
        //        dt_UserProjectSchedule.Columns[i].ColumnName = "课件总时长(分钟)";
        //        dt_UserProjectSchedule.Columns[i].SetOrdinal(6);

        //    }
        //    else if (columnName == "ExamCount")
        //    {
        //        dt_UserProjectSchedule.Columns[i].ColumnName = "考试次数";
        //        dt_UserProjectSchedule.Columns[i].SetOrdinal(7);

        //    }
        //    else if (columnName == "PaperScore")
        //    {
        //        dt_UserProjectSchedule.Columns[i].ColumnName = "试卷总分";
        //        dt_UserProjectSchedule.Columns[i].SetOrdinal(8);

        //    }
        //    else if (columnName == "LastScore")
        //    {
        //        dt_UserProjectSchedule.Columns[i].ColumnName = "试卷实际得分";
        //        dt_UserProjectSchedule.Columns[i].SetOrdinal(9);

        //    }
        //    else
        //    {
        //        list.Add(dt_UserProjectSchedule.Columns[i].ColumnName);
        //    }
        //}
        
       



        //for (int i = 0; i < list.Count; i++)
        //{
        //    dt_UserProjectSchedule.Columns.Remove(list[i].ToString());
        //}
        //dt_UserProjectSchedule.Columns["资源名称"].SetOrdinal(1);
        //dt_UserProjectSchedule.Columns["试卷实际得分"].SetOrdinal(9);
        //Excel objExcel = new Excel();
        //objExcel.ToExcel(dt_UserProjectSchedule, this.Page, "培训进度统计", "培训进度统计信息", "ProjectInfo");
    }
    protected void btnPrinter_Click(object sender, EventArgs e)
    {

    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        string search = GetSearch();
        BinderGV(search, AspNetPager1.CurrentPageIndex);
    }
    protected void btnExport_All_Click(object sender, EventArgs e)
    {
        //string search = GetSearch();
        //DataTable dt_ProjectUserList = new DataTable();
        //dt_ProjectUserList = objManagerClassMember.GetProjectUserList(search, 1, objManagerClassMember.GetProjectUserListCount(search));
        //ExportList(dt_ProjectUserList);
    }
}
